Skip to content

Conversation

@RAprogramm
Copy link
Owner

Closes #43

Problem

When code changes are pushed to main, both workflows trigger simultaneously:

  • benchmark.yml (triggers on src/, benches/, Cargo.toml)
  • tokei-metrics.yml (triggers on src/, tests/, benches/**, etc.)

Both workflows:

  1. Checkout main
  2. Update README.md
  3. Commit and push

If they run in parallel, second push fails with:

! [rejected]        main -> main (fetch first)
error: failed to push some refs

Failed run example: https://github.com/RAprogramm/cstring-array/actions/runs/18625288263

Solution

Added git pull --rebase origin main before git push in both workflows.

Changes

benchmark.yml:179

git commit -m "chore: update benchmark results [skip ci]"
git pull --rebase origin main  # ← ADDED
git push

tokei-metrics.yml:159

git commit -m "chore: update tokei metrics [skip ci]"
git pull --rebase origin main  # ← ADDED
git push

Benefits

  • No more failed workflow runs
  • Both metrics update successfully even when running in parallel
  • Race-safe concurrent execution
  • Changes from parallel workflows are merged via rebase

How it works

  1. Workflow A: commits changes
  2. Workflow B: commits changes (in parallel)
  3. Workflow A: pulls and rebases → pushes successfully
  4. Workflow B: pulls and rebases → merges A's changes → pushes successfully

Both workflows complete without conflicts.

Testing

  • Workflow syntax validated
  • REUSE compliance maintained
  • Will be tested on next code push that triggers both workflows

- Add git pull --rebase origin main before git push
- Prevents race condition when workflows run in parallel
- Both benchmark and tokei-metrics can now update README safely

Problem:
- benchmark.yml and tokei-metrics.yml trigger simultaneously
- Both checkout, modify README, commit, and push
- Second push fails with 'rejected' error

Solution:
- Pull and rebase before pushing
- Merges changes from parallel workflow
- Safe concurrent execution

Related: Closes #43
@RAprogramm RAprogramm merged commit 8cabe16 into main Oct 19, 2025
3 checks passed
@RAprogramm RAprogramm deleted the 43 branch October 19, 2025 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix race condition in benchmark and tokei-metrics workflows

1 participant